from celery import Celery
from django.conf import settings
import os

# 为celery设置环境变量
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings')

# 创建应用
app = Celery("demo")
# 配置应用
app.conf.update(
    # 使用项目数据库存储任务执行结果
    CELERY_RESULT_BACKEND='django-db',
    # result_backend='redis://:failytestredis@43.254.54.93:63791/12',
    BROKER_URL='redis://:failytestredis@43.254.54.93:63791/11',
    CELERYBEAT_SCHEDULER='django_celery_beat.schedulers.DatabaseScheduler',
)
# 设置app自动加载任务
# 从已经安装的app中查找任务
app.autodiscover_tasks(settings.INSTALLED_APPS)
